package com.subsequent.controller;

import com.github.pagehelper.PageInfo;
import com.subsequent.dto.AppointmentsQueryDTO;
import com.subsequent.pojo.Appointments;
import com.subsequent.service.AppointmentsService;
import com.subsequent.utils.Result;
import com.subsequent.vo.AppointmentsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/appointments")
public class AppointmentsController {
    @Autowired
    private AppointmentsService appointmentsService;

    /**
     * 分页查询预约信息
     * @param appointmentsQueryDTO
     * @return
     */
    @RequestMapping("/page")
    public Result page(@RequestBody AppointmentsQueryDTO appointmentsQueryDTO) {
        PageInfo<AppointmentsVO> appointmentsList = appointmentsService.getAppointmentsList(appointmentsQueryDTO);
        return Result.success(appointmentsList);
    }

    /**
     * 修改预约状态
     * @param appointmentsVO
     * @return
     */
    @RequestMapping("/status")
    public Result updateStatus(@RequestBody AppointmentsVO appointmentsVO) {
        int i = appointmentsService.updateStatus(appointmentsVO);
        return Result.success("已到诊",  i);
    }

    /**
     * 全部退款
     * @param appointmentsVO
     * @return
     */
    @RequestMapping("/fee")
    public Result updateFee(@RequestBody AppointmentsVO appointmentsVO) {
        int i = appointmentsService.updateFee(appointmentsVO);
        return Result.success("已经全额退款",  i);
    }
}
